<template>
  <div>CommonExample</div>
  <dynamic-form :formConfig="formConfig" :getOptionFun="getOptionFun" :formData="formData"
                :handleSubmitButton="handleSubmitButton" />
</template>
<script setup lang="ts">
import { formConfig } from './config'
import type { FormData } from '@/components/DynamicForm/type'
import DynamicForm from '@/components/DynamicForm/DynamicForm.vue'
import { reactive } from 'vue'
import options, { OptionsUtil } from '../../core/optionsUtil'
import { ElMessage } from 'element-plus'

const formData = reactive<FormData>({})

function getOptionFun(tranCode: keyof OptionsUtil) {
  if (tranCode) {
    return options[tranCode]
  }
}

function handleSubmitButton(json: FormData) {
  ElMessage(JSON.stringify(json))
  ElMessage(JSON.stringify(formData))
}
</script>
<style scoped>

</style>
